********************************************************************************
*
* DrawScriptList -
*

DrawScriptList	START

                    USING    HEGlobals
                    USING    SEGlobals

	Debug	'DrawScriptList'

RectPtr	equ	$F
MemRecPtr	equ	$B
ListHand	equ	$7
ListPtr 	equ	$7
ReturnPtr	equ	$4
DataBank            equ	$3
DirectPage	equ	$1

                    phb

                    phk
                    plb

	phd

	tsc
	tcd

	PushLong <RectPtr
	_EraseRect

	ldy	#left
	lda	[RectPtr],y
	clc
	adc	#10
	pha
	ldy	#bottom
	lda	[RectPtr],y
	dec	a
	dec	a
	pha
	_MoveTo

                    lda	#4
                    sta	OffscreenLineBuffer

                    lda	[MemRecPtr]
                    pha
                    PushPtr	OffscreenLineBuffer+1
                    PushWord	#4
                    _Int2Hex

	PushPtr	OffscreenLineBuffer
	_DrawString

	ldy	#left
	lda	[RectPtr],y
	clc
	adc	#50
	pha
	ldy	#bottom
	lda	[RectPtr],y
	dec	a
	dec	a
	pha
	_MoveTo

                    pha
                    pha
                    _GetCharExtra
	
                    lda	<MemRecPtr
	clc
                    adc	#8
                    tax
                    lda	<MemRecPtr+2
                    adc	#0

                    pha	
                    phx                      ;for DrawString

                    pha
                    pha
                    phx
                    _StringWidth             ;find out how long the name is
                    
                    PushLong	<ListHand
                    jsr	DerefHand
                    sta      ListPtr
                    stx	ListPtr+2

* Calculate how much space we have for the name by taking the width of the list
* and subtracting the indent loc for the name.

                    ldy	#octlRect+right
                    lda	[ListPtr],y
                    ldy	#octlRect+left
                    sec
                    sbc	[ListPtr],y
                    sbc	#50	;name indent
                    cmp	1,s
                    bge	DrawCurString

                    PushLong	#$FFFF0000	;-1.0
                    _SetCharExtra
	
DrawCurString       ANOP
	
                    pla		;StringWidth result

                    _DrawString

                    _SetCharExtra

	ldy	#4
	lda	[MemRecPtr],y
	and	#memSelected	;get bit 7
	beq	AsIs	; don't hilight
	
	PushLong <RectPtr        ;this item is selected
	_InvertRect

AsIs	ANOP

	pld

                    plb

	lda	1,S	;move the rtl up over the inputs
	sta	13,S
	lda	2,S
	sta	14,S

	tsc		;yank the inputs
	clc
	adc	#12
	tcs

	rtl

	END
